package a.f;

import a.c.*;
import a.f.c.i;
import a.i.ub;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;

public final class tc
{
  private q a;
  private dc b;
  public static int c;
  
  public tc(q paramq)
  {
    this(paramq, null);
  }
  
  public tc(o paramo)
  {
    this(paramo, paramo);
  }
  
  public tc(q paramq, dc paramdc)
  {
    this.a = paramq;
    this.b = paramdc;
  }
  
  public void a(String paramString)
    throws IOException
  {
    a(new File(paramString));
  }
  
  public void a(File paramFile)
    throws IOException
  {
    FileWriter localFileWriter = new FileWriter(paramFile);
    a(localFileWriter);
    localFileWriter.close();
  }
  
  public void a(Writer paramWriter)
    throws IOException
  {
    boolean bool = o.eg;
    int n = o.dg;
    k localk1 = this.a.c(i.b);
    k localk2 = this.a.c(i.a);
    k localk3 = this.a.c(i.c);
    int i = ((bool) || (localk1 != null)) && ((bool) || ((localk2 != null) && (localk3 != null))) ? 1 : 0;
    HashMap localHashMap = new HashMap();
    if (i != 0)
    {
      localObject1 = this.a.v();
      do
      {
        if (!((a.c.w)localObject1).e()) {
          break;
        }
        localHashMap.put(localk2.get(((a.c.w)localObject1).d()), ((a.c.w)localObject1).d());
        ((a.c.w)localObject1).f();
      } while (n == 0);
    }
    Object localObject1 = new a_(paramWriter);
    ((a_)localObject1).b("Creator", "yFiles-LayoutGraphWriter");
    ((a_)localObject1).b("Version", ub.a());
    ((a_)localObject1).a("graph");
    ((a_)localObject1).b("label", "");
    ((a_)localObject1).a("directed", 1);
    if (!bool) {
      if (i != 0) {
        ((a_)localObject1).a("hierarchic", 1);
      }
    }
    int j = 0;
    Object localObject2 = this.a.v();
    if (((a.c.w)localObject2).e()) {
      j++;
    }
    Object localObject3;
    label345:
    Object localObject4;
    while (bool)
    {
      localObject3 = ((a.c.w)localObject2).d();
      ((a_)localObject1).a("node");
      ((a_)localObject1).a("id", ((e)localObject3).f());
      if (!bool)
      {
        if (i == 0) {
          break label345;
        }
        if (bool) {}
      }
      else if (localk3.getBool(localObject3))
      {
        ((a_)localObject1).a("isGroup", 1);
      }
      if (localk1.get(localObject3) != null) {
        ((a_)localObject1).a("gid", ((e)localHashMap.get(localk1.get(localObject3))).f());
      }
      if (!bool)
      {
        if (this.b != null) {
          ((a_)localObject1).a("graphics");
        }
      }
      else
      {
        localObject4 = this.b.d(localObject3);
        ((a_)localObject1).a("x", (float)((zc)localObject4).a() + ((zc)localObject4).c() * 0.5D);
        ((a_)localObject1).a("y", (float)((zc)localObject4).b() + ((zc)localObject4).d() * 0.5D);
        ((a_)localObject1).a("w", (float)((zc)localObject4).c());
        ((a_)localObject1).a("h", (float)((zc)localObject4).d());
        ((a_)localObject1).b("type", "rectangle");
        ((a_)localObject1).c();
      }
      ((a_)localObject1).c();
      ((a.c.w)localObject2).f();
      if (n == 0) {
        break;
      }
    }
    localObject2 = this.a.w();
    label825:
    do
    {
      if (!((m)localObject2).e()) {
        break;
      }
      localObject3 = ((m)localObject2).a();
      ((a_)localObject1).a("edge");
      ((a_)localObject1).a("source", ((d)localObject3).e().f());
      ((a_)localObject1).a("target", ((d)localObject3).f().f());
      if (n != 0) {
        return;
      }
      if ((bool) || (this.b != null))
      {
        localObject4 = this.b.e(localObject3);
        ((a_)localObject1).a("graphics");
        int k = ((zb)localObject4).a();
        if (!bool)
        {
          if (k > 0)
          {
            ((a_)localObject1).a("Line");
            ((a_)localObject1).a("point");
            zc localzc1 = this.b.d(((d)localObject3).e());
            localObject5 = ((zb)localObject4).c();
            ((a_)localObject1).a("x", (float)(((a.d.w)localObject5).a + localzc1.a() + localzc1.c() * 0.5D));
            ((a_)localObject1).a("y", (float)(((a.d.w)localObject5).b + localzc1.b() + localzc1.d() * 0.5D));
            ((a_)localObject1).c();
            int m = 0;
            if (m < k)
            {
              ((a_)localObject1).a("point");
              localObject5 = ((zb)localObject4).a(m);
              ((a_)localObject1).a("x", (float)((a.d.w)localObject5).a);
            }
            while (bool)
            {
              ((a_)localObject1).a("y", (float)((a.d.w)localObject5).b);
              ((a_)localObject1).c();
              m++;
              if ((!bool) && (n != 0)) {
                break label825;
              }
              if (n == 0) {
                break;
              }
            }
            ((a_)localObject1).a("point");
            localzc2 = this.b.d(((d)localObject3).f());
            localObject5 = ((zb)localObject4).d();
            ((a_)localObject1).a("x", (float)(((a.d.w)localObject5).a + localzc2.a() + localzc2.c() * 0.5D));
            ((a_)localObject1).a("y", (float)(((a.d.w)localObject5).b + localzc2.b() + localzc2.d() * 0.5D));
            ((a_)localObject1).c();
            ((a_)localObject1).c();
          }
          ((a_)localObject1).c();
          ((a_)localObject1).a("edgeAnchor");
        }
        a.d.w localw = ((zb)localObject4).c();
        zc localzc2 = this.b.d(((d)localObject3).e());
        if (!bool) {
          if (localw.a != 0.0D) {
            ((a_)localObject1).a("xSource", (float)(2.0D * localw.a / localzc2.c()));
          }
        }
        if (localw.b != 0.0D) {
          ((a_)localObject1).a("ySource", (float)(2.0D * localw.b / localzc2.d()));
        }
        Object localObject5 = this.b.d(((d)localObject3).f());
        localw = ((zb)localObject4).d();
        if (!bool) {
          if (localw.a != 0.0D) {
            ((a_)localObject1).a("xTarget", (float)(2.0D * localw.a / ((zc)localObject5).c()));
          }
        }
        if (localw.b != 0.0D) {
          ((a_)localObject1).a("yTarget", (float)(2.0D * localw.b / ((zc)localObject5).d()));
        }
        ((a_)localObject1).c();
      }
      ((a_)localObject1).c();
      ((m)localObject2).f();
    } while (n == 0);
    if (!bool) {
      ((a_)localObject1).c();
    }
  }
  
  static class a_
  {
    private int a;
    private Writer b;
    private StringBuffer d = new StringBuffer(100);
    private String e;
    
    public a_(Writer paramWriter)
    {
      this.d.append("\t\t\t\t");
      this.a = 0;
      this.b = paramWriter;
      this.e = System.getProperty("line.separator");
    }
    
    protected void a()
      throws IOException
    {
      boolean bool = o.eg;
      int j = o.dg;
      int i = this.a;
      do
      {
        do
        {
          if (this.d.length() >= i) {
            break;
          }
          this.d.append(this.d.toString());
          if ((!bool) && (j != 0)) {
            return;
          }
        } while (j == 0);
      } while (bool);
      this.b.write(this.d.toString(), 0, i);
    }
    
    public void a(String paramString)
      throws IOException
    {
      a();
      this.b.write(paramString);
      this.b.write(this.e);
      a();
      this.b.write("[" + this.e);
      this.a += 1;
    }
    
    protected void a(String paramString1, String paramString2)
      throws IOException
    {
      a();
      this.b.write(paramString1);
      this.b.write(9);
      this.b.write(paramString2);
      this.b.write(this.e);
    }
    
    public void a(String paramString, double paramDouble)
      throws IOException
    {
      a(paramString, Double.toString(paramDouble));
    }
    
    public void a(String paramString, int paramInt)
      throws IOException
    {
      a(paramString, Integer.toString(paramInt));
    }
    
    public void a(String paramString, Number paramNumber)
      throws IOException
    {
      a(paramString, paramNumber.toString());
    }
    
    public void a(String paramString, boolean paramBoolean)
      throws IOException
    {
      a(paramString, paramBoolean ? "1" : "0");
    }
    
    public void b(String paramString1, String paramString2)
      throws IOException
    {
      a(paramString1, b(paramString2));
    }
    
    public void a(String paramString, Object paramObject)
      throws IOException
    {
      boolean bool = o.eg;
      int i = o.dg;
      if ((bool) || (paramObject != null))
      {
        if (!bool) {
          if ((paramObject instanceof Double))
          {
            a(paramString, ((Double)paramObject).doubleValue());
            if ((!bool) && (i == 0)) {
              return;
            }
          }
        }
        if (!bool) {
          if ((paramObject instanceof Integer))
          {
            a(paramString, ((Integer)paramObject).intValue());
            if ((!bool) && (i == 0)) {
              return;
            }
          }
        }
        if (!bool) {
          if ((paramObject instanceof Number))
          {
            a(paramString, ((Number)paramObject).doubleValue());
            if (!bool) {
              if (i == 0) {
                return;
              }
            }
          }
          else
          {
            if (bool) {
              break label139;
            }
            b(paramString, paramObject.toString());
          }
        }
        if (i == 0) {
          return;
        }
      }
      label139:
      b(paramString, "null");
    }
    
    protected String b(String paramString)
    {
      boolean bool = o.eg;
      int m = o.dg;
      int i = 0;
      int j = 0;
      label92:
      label100:
      do
      {
        if (j >= paramString.length()) {
          break;
        }
        k = paramString.charAt(j);
        if ((!bool) && (m != 0)) {
          break label114;
        }
        if (!bool)
        {
          if (k <= 255) {
            if (bool) {
              break label92;
            }
          }
        }
        else if (k != 10)
        {
          if (bool) {
            break label92;
          }
          if (k != 38)
          {
            if (bool) {
              continue;
            }
            if (k != 34) {
              break label100;
            }
          }
        }
        i = 1;
        if (!bool)
        {
          if (m == 0) {
            break;
          }
          j++;
        }
      } while (m == 0);
      if ((!bool) && (i == 0)) {
        label114:
        return '"' + paramString + '"';
      }
      StringBuffer localStringBuffer = new StringBuffer(paramString.length() + 5);
      localStringBuffer.append('"');
      int k = 0;
      label313:
      do
      {
        if (k >= paramString.length()) {
          break;
        }
        if (bool) {
          break label337;
        }
        char c = paramString.charAt(k);
        if (m != 0) {
          break label333;
        }
        if (!bool) {
          if (c > 'ÿ')
          {
            localStringBuffer.append("&#x");
            localStringBuffer.append(Integer.toHexString(c));
            localStringBuffer.append(';');
            if (bool) {
              continue;
            }
            if (m == 0) {
              break label313;
            }
          }
        }
        if (!bool) {}
        switch (c)
        {
        case '"': 
          localStringBuffer.append("&quot;");
          if (bool) {
            continue;
          }
          if (m == 0) {
            break;
          }
        case '&': 
          localStringBuffer.append("&amp;");
          if (bool) {
            continue;
          }
          if (m == 0) {
            break;
          }
        default: 
          localStringBuffer.append(c);
        }
        k++;
      } while (m == 0);
      if (!bool) {
        localStringBuffer.append('"');
      }
      label333:
      label337:
      return localStringBuffer.toString();
    }
    
    public void c()
      throws IOException
    {
      this.a -= 1;
      a();
      this.b.write("]" + this.e);
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.tc

 * JD-Core Version:    0.7.0.1

 */